package com.laowang.common.utils;
import com.google.common.net.MediaType;
import okhttp3.*;


import java.io.*;

import com.laowang.common.utils.http.HttpKit;

import org.springframework.web.bind.annotation.RequestBody;


import java.io.*;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

/**
 * @Auther laowang
 * @Date 2023/5/8
 * @Description
 */
public class AccessTokenUtil {

   public static final String apikey= "KUsiyOITPlnph4BX1RMRKtQw";
   public static final String apiSecrect ="px7NFxZSYe6FdjeEvoj2Ww9YcpPnZXGx";

    public static void main(String []args) throws IOException{
        String url ="https://aip.baidubce.com/oauth/2.0/token?client_id=%s&sclient_secret=%s&grant_type=client_credentials";
        String format = String.format(url, apikey, apiSecrect);
        System.out.println(format);

        try {
            Map<String,String> headers = new HashMap<>();
            headers.put("Content-Type", "application/json");
            headers.put("Accept", "application/json");

            Map<String,String> body = new HashMap<>();
            body.put("application/json", "charset=utf-8");
            String post = HttpKit.get(format,headers);
            System.out.println(post);
        } catch (ExecutionException | InterruptedException | NoSuchAlgorithmException | KeyManagementException | NoSuchProviderException e) {
            e.printStackTrace();
        }


    }


}
